import { Component, OnInit, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';

@Component({
  selector: 'app-confirm-dialog',
  template: `
    <h2 mat-dialog-title>{{title}}</h2>
    <mat-dialog-content>
      {{content}}
    </mat-dialog-content>
    <mat-dialog-actions>
      <button type="button" mat-button color="primary" (click)="heandClick(true)">确定</button>
      <button type="button" mat-button mat-dialog-close (click)="heandClick(false)">取消</button>
    </mat-dialog-actions>
  `,
  styles: []
})
export class ConfirmDialogComponent implements OnInit {
  title: string = "";
  content: string = "";
  constructor(private dialogRef:MatDialogRef<ConfirmDialogComponent>,
    @Inject(MAT_DIALOG_DATA) private data
    ) { }

  ngOnInit() {
    this.title = this.data.title;
    this.content = this.data.content;
  }
  heandClick(result:boolean){
    this.dialogRef.close(result)
  }

}
